package com.prs.crm.action.archives;

import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.courser.ui.TreeNode;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.ConnSqlServer;
import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.context.FileUtil;
import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.archives.ArchivesManager;
import com.prs.crm.domain.archives.ArchivesType;
import com.prs.crm.domain.archives.KeepTime;
import com.prs.crm.domain.archives.SecretLevel;
import com.prs.crm.domain.archives.WaitBorrow;
import com.prs.crm.domain.hr.ShareEim;
import com.prs.crm.service.AttachmentService;
import com.prs.crm.service.archives.ArchivesManagerService;
import com.prs.crm.service.archives.ArchivesTypeService;
import com.prs.crm.service.archives.KeepTimeService;
import com.prs.crm.service.archives.SecretLevelService;
import com.prs.crm.service.archives.WaitBorrowService;
import com.prs.crm.service.person.ShareEimService;

public class ArchivesManagerAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private Integer[] ids;
	private PaginationSupport pagination;
	private ArchivesManager archivesManager;
	private ArchivesManagerService archivesManagerService;
	private List<KeepTime> keepTime;
	private KeepTimeService keepTimeService;
	private List<ArchivesType> archivesType;
	private ArchivesTypeService archivesTypeService;
	private List<SecretLevel> secretLevel;
	private SecretLevelService secretLevelService;
	private String typeIds;
	private File upload;
	private String uploadFileName;

	private WaitBorrowService waitBorrowService;

	private Collection<TreeNode> nodes;
	
	private PaginationSupport paginationSupport;
	private AttachmentService attachmentService;
	private String t1;
	private String t2;
	private String t3;
	private String t4;
	private String t5;
	private String t6;
	private String t7;
	private String t8;
	private String t9;
	private String t10;
	private String t11;
	private String t12;
	private String t13;
	private ResultSet rs;
	private ShareEimService shareEimService;
	public ShareEimService getShareEimService() {
		return shareEimService;
	}

	public void setShareEimService(ShareEimService shareEimService) {
		this.shareEimService = shareEimService;
	}

	public String getT5() {
		return t5;
	}

	public void setT5(String t5) {
		this.t5 = t5;
	}

	public String getT6() {
		return t6;
	}

	public void setT6(String t6) {
		this.t6 = t6;
	}

	public String getT7() {
		return t7;
	}

	public void setT7(String t7) {
		this.t7 = t7;
	}

	public String getT8() {
		return t8;
	}

	public void setT8(String t8) {
		this.t8 = t8;
	}

	public String getT9() {
		return t9;
	}

	public void setT9(String t9) {
		this.t9 = t9;
	}

	public String getT10() {
		return t10;
	}

	public void setT10(String t10) {
		this.t10 = t10;
	}

	public String getT11() {
		return t11;
	}

	public void setT11(String t11) {
		this.t11 = t11;
	}

	public String getT12() {
		return t12;
	}

	public void setT12(String t12) {
		this.t12 = t12;
	}

	public String getT13() {
		return t13;
	}

	public void setT13(String t13) {
		this.t13 = t13;
	}
	private List<Object[]> children;
	public List<Object[]> getChildren() {
		return children;
	}

	public void setChildren(List<Object[]> children) {
		this.children = children;
	}

	public String getT1() {
		return t1;
	}

	public void setT1(String t1) {
		this.t1 = t1;
	}

	public String getT2() {
		return t2;
	}

	public void setT2(String t2) {
		this.t2 = t2;
	}

	public String getT3() {
		return t3;
	}

	public void setT3(String t3) {
		this.t3 = t3;
	}

	public String getT4() {
		return t4;
	}

	public void setT4(String t4) {
		this.t4 = t4;
	}

	public AttachmentService getAttachmentService() {
		return attachmentService;
	}

	public void setAttachmentService(AttachmentService attachmentService) {
		this.attachmentService = attachmentService;
	}

	public PaginationSupport getPaginationSupport() {
		return paginationSupport;
	}

	public void setPaginationSupport(PaginationSupport paginationSupport) {
		this.paginationSupport = paginationSupport;
	}

	public String getTypeIds() {
		return typeIds;
	}

	public void setTypeIds(String typeIds) {
		this.typeIds = typeIds;
	}

	public Collection<TreeNode> getNodes() {
		return nodes;
	}

	public void setNodes(Collection<TreeNode> nodes) {
		this.nodes = nodes;
	}

	public WaitBorrowService getWaitBorrowService() {
		return waitBorrowService;
	}

	public void setWaitBorrowService(WaitBorrowService waitBorrowService) {
		this.waitBorrowService = waitBorrowService;
	}

	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		this.upload = upload;
	}

	public String getUploadFileName() {
		return uploadFileName;
	}

	public void setUploadFileName(String uploadFileName) {
		this.uploadFileName = uploadFileName;
	}

	public Integer[] getIds() {
		return ids;
	}

	public void setIds(Integer[] ids) {
		this.ids = ids;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public ArchivesManager getArchivesManager() {
		return archivesManager;
	}

	public void setArchivesManager(ArchivesManager archivesManager) {
		this.archivesManager = archivesManager;
	}

	public ArchivesManagerService getArchivesManagerService() {
		return archivesManagerService;
	}

	public void setArchivesManagerService(
			ArchivesManagerService archivesManagerService) {
		this.archivesManagerService = archivesManagerService;
	}

	public List<KeepTime> getKeepTime() {
		return keepTime;
	}

	public void setKeepTime(List<KeepTime> keepTime) {
		this.keepTime = keepTime;
	}

	public KeepTimeService getKeepTimeService() {
		return keepTimeService;
	}

	public void setKeepTimeService(KeepTimeService keepTimeService) {
		this.keepTimeService = keepTimeService;
	}

	public List<ArchivesType> getArchivesType() {
		return archivesType;
	}

	public void setArchivesType(List<ArchivesType> archivesType) {
		this.archivesType = archivesType;
	}

	public ArchivesTypeService getArchivesTypeService() {
		return archivesTypeService;
	}

	public void setArchivesTypeService(ArchivesTypeService archivesTypeService) {
		this.archivesTypeService = archivesTypeService;
	}

	public List<SecretLevel> getSecretLevel() {
		return secretLevel;
	}

	public void setSecretLevel(List<SecretLevel> secretLevel) {
		this.secretLevel = secretLevel;
	}

	public SecretLevelService getSecretLevelService() {
		return secretLevelService;
	}

	public void setSecretLevelService(SecretLevelService secretLevelService) {
		this.secretLevelService = secretLevelService;
	}

	@Action("listArchivesManager")
	public String listArchivesManager() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				ArchivesManager.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getArchivesManagerService().listByPage(
				criteria, pagination));
		return SUCCESS;
	}
	@Action("listArchivesManagers")
	public String listArchivesManagers() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				ArchivesManager.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getArchivesManagerService().listByPage(
				criteria, pagination));
		return SUCCESS;
	}

	@Action("selectArchivesManager")
	public String selectArchivesManager() {
		this.listArchivesManager();
		return SUCCESS;
	}

	@Action("selectArchivesManagers")
	public String selectArchivesManagers() {
		this.listArchivesManager();
		return SUCCESS;
	}

	@Action("selectArchivates")
	public String selectArchivates(){
		return SUCCESS;
	}
	@Action("editArchivesManager")
	public String editArchivesManager() {
		if (ids != null) {
			this.archivesManager = this.getArchivesManagerService().get(ids[0]);
		}
		this.archivesType = this.getArchivesTypeService().getAllArchivesType();
		this.keepTime = this.getKeepTimeService().getAllKeepTime();
		this.secretLevel = this.getSecretLevelService().getAllSecretLevel();
		return SUCCESS;
	}
	@Action("editArchivesManagerSee")
	public String editArchivesManagerSee() {
		if (ids != null) {
			this.archivesManager = this.getArchivesManagerService().get(ids[0]);
		}
		this.archivesType = this.getArchivesTypeService().getAllArchivesType();
		this.keepTime = this.getKeepTimeService().getAllKeepTime();
		this.secretLevel = this.getSecretLevelService().getAllSecretLevel();
		return SUCCESS;
	}
	
	@Action("editArchivesManagers")
	public String editArchivesManagers() {
		this.archivesType = this.getArchivesTypeService().getAllArchivesType();
		this.keepTime = this.getKeepTimeService().getAllKeepTime();
		this.secretLevel = this.getSecretLevelService().getAllSecretLevel();
		return SUCCESS;
	}

	@Action("viewArchivesManager")
	public String viewArchivesManager() {
		if (ids != null) {
			this.archivesManager = this.getArchivesManagerService().get(ids[0]);
		}
		this.archivesType = this.getArchivesTypeService().getAllArchivesType();
		this.keepTime = this.getKeepTimeService().getAllKeepTime();
		this.secretLevel = this.getSecretLevelService().getAllSecretLevel();
		return SUCCESS;
	}

	@Action(value = "saveArchivesManager", results = {
			@Result(name = "success", type = "redirect", location = "listArchivesManager"),
			@Result(name = "error", type = "chain", location = "editArchivesManager") })
	public String saveArchivesManager() {
		if (upload != null) {
			Attachment attach=FileUtil.getInstance().createAttach(upload, uploadFileName);
			this.getAttachmentService().save(attach);
			archivesManager.setAttach(attach);
		}
		if (archivesManager.getNumber()==null || "".equals(archivesManager.getNumber().trim())) {
			this.addActionError("档案编号不能为空！");
			return ERROR;
		}
		if (archivesManager.getArchivesName()==null || "".equals(archivesManager.getArchivesName().trim())) {
			this.addActionError("档案名称不能为空！");
			return ERROR;
		}
		if(archivesManager.getId()==null){
		List<ArchivesManager> am=this.getArchivesManagerService().getAllArchivesManager();
		int a=0;
		for (ArchivesManager ar : am) {
			if (ar.getNumber().equals(archivesManager.getNumber())) {
				a++;	
			}
		}
		if (a>0) {
			this.addActionError("档案编号已经存在！");
				return ERROR;
		}
		archivesManager.setState(0);
		this.getArchivesManagerService().save(archivesManager);
		}else{
			this.getArchivesManagerService().submit(archivesManager);
		}
		return SUCCESS;
	}
	@Action(value = "saveArchivesManagers", results = {
			@Result(name = "success", type = "redirect", location = "listArchivesManager"),
			@Result(name = "error", type = "chain", location = "editArchivesManagers") })
	public String saveArchivesManagers() {
		if (upload != null) {
			Attachment attach=FileUtil.getInstance().createAttach(upload, uploadFileName);
			this.getAttachmentService().save(attach);
			archivesManager.setAttach(attach);
		}
		if (archivesManager.getNumber()==null || "".equals(archivesManager.getNumber().trim())) {
			this.addActionError("档案编号不能为空！");
			return ERROR;
		}
		if (archivesManager.getArchivesName()==null || "".equals(archivesManager.getArchivesName().trim())) {
			this.addActionError("档案名称不能为空！");
			return ERROR;
		}
		if(archivesManager.getId()==null){
		List<ArchivesManager> am=this.getArchivesManagerService().getAllArchivesManager();
		int a=0;
		for (ArchivesManager ar : am) {
			if (ar.getNumber().equals(archivesManager.getNumber())) {
				a++;	
			}
		}
		if (a>0) {
			this.addActionError("档案编号已经存在！");
				return ERROR;
		}
		archivesManager.setState(0);
		this.getArchivesManagerService().save(archivesManager);
		}else{
			this.getArchivesManagerService().submit(archivesManager);
		}
		return SUCCESS;
	}

	@Action(value = "saveContinueArchivesManager", results = {
			@Result(name = "success", type = "redirect", location = "editArchivesManager"),
			@Result(name = "error", type = "chain", location = "editArchivesManager") })
	public String saveContinueArchivesManager() {
		if (upload != null) {
			Attachment attach=FileUtil.getInstance().createAttach(upload, uploadFileName);
			this.getAttachmentService().save(attach);
			archivesManager.setAttach(attach);
		}
		if (archivesManager.getNumber()==null || "".equals(archivesManager.getNumber().trim())) {
			this.addActionError("档案编号不能为空！");
			return ERROR;
		}
		if (archivesManager.getArchivesName()==null || "".equals(archivesManager.getArchivesName().trim())) {
			this.addActionError("档案名称不能为空！");
			return ERROR;
		}
		if(archivesManager.getId()==null){
		List<ArchivesManager> am=this.getArchivesManagerService().getAllArchivesManager();
		int a=0;
		for (ArchivesManager ar : am) {
			if (ar.getNumber().equals(archivesManager.getNumber())) {
				a++;	
			}
		}
		if (a>0) {
			this.addActionError("档案编号已经存在！");
				return ERROR;
		}
		archivesManager.setState(0);
		this.getArchivesManagerService().save(archivesManager);
		}else{
			this.getArchivesManagerService().submit(archivesManager);
		}
		return SUCCESS;
	}
	@Action(value = "saveContinueArchivesManagers", results = {
			@Result(name = "success", type = "redirect", location = "editArchivesManagers"),
			@Result(name = "error", type = "chain", location = "editArchivesManagers") })
	public String saveContinueArchivesManagers() {
		if (upload != null) {
			Attachment attach=FileUtil.getInstance().createAttach(upload, uploadFileName);
			this.getAttachmentService().save(attach);
			archivesManager.setAttach(attach);
		}
		if (archivesManager.getNumber()==null || "".equals(archivesManager.getNumber().trim())) {
			this.addActionError("档案编号不能为空！");
			return ERROR;
		}
		if (archivesManager.getArchivesName()==null || "".equals(archivesManager.getArchivesName().trim())) {
			this.addActionError("档案名称不能为空！");
			return ERROR;
		}
		if (archivesManager.getId()==null) {
			List<ArchivesManager> am=this.getArchivesManagerService().getAllArchivesManager();
			int a=0;
			for (ArchivesManager ar : am) {
				if (ar.getNumber().equals(archivesManager.getNumber())) {
					a++;	
				}
			}
			if (a>0) {
				this.addActionError("档案编号已经存在！");
					return ERROR;
			}
			archivesManager.setState(0);
			this.getArchivesManagerService().save(archivesManager);	
		}else{
			this.getArchivesManagerService().submit(archivesManager);	
		}	
		return SUCCESS;
	}

	@Action(value = "saveArchivesManagerSee", results = {
			@Result(name = "success", type = "redirect", location = "selectArchivesManagers"),
			@Result(name = "error", type = "chain", location = "editArchivesManagerSee") })
	public String saveArchivesManagerSee() {
		if (upload != null) {
			Attachment attach=FileUtil.getInstance().createAttach(upload, uploadFileName);
			this.getAttachmentService().save(attach);
			archivesManager.setAttach(attach);
		}
		if (archivesManager.getNumber()==null || "".equals(archivesManager.getNumber().trim())) {
			this.addActionError("档案编号不能为空！");
			return ERROR;
		}
		if (archivesManager.getArchivesName()==null || "".equals(archivesManager.getArchivesName().trim())) {
			this.addActionError("档案名称不能为空！");
			return ERROR;
		}
		if(archivesManager.getId()==null){
		List<ArchivesManager> am=this.getArchivesManagerService().getAllArchivesManager();
		int a=0;
		for (ArchivesManager ar : am) {
			if (ar.getNumber().equals(archivesManager.getNumber())) {
				a++;	
			}
		}
		if (a>0) {
			this.addActionError("档案编号已经存在！");
				return ERROR;
		}
		archivesManager.setState(0);
		this.getArchivesManagerService().save(archivesManager);
		}else{
			this.getArchivesManagerService().submit(archivesManager);
		}
		return SUCCESS;
	}
	@Action(value = "removeArchivesManager", results = {
			@Result(name = "success", type = "redirect", location = "listArchivesManager"),
			@Result(name = "error", type = "chain", location = "listArchivesManager") })
	public String removeArchivesManager() {
		if (ids != null) {
			this.archivesManager = this.getArchivesManagerService().get(ids[0]);
		}
		if (archivesManager.getState()==1) {
			this.addActionError("此档案已被借出，不能删除");
			return ERROR;
		}
		ArchivesManager ams=this.getArchivesManagerService().getaArchivesManagers1(archivesManager.getId());
		if (ams!=null) {
			WaitBorrow wbs=this.getWaitBorrowService().getWaitBorrows(ams.getNumber());
			if (wbs!=null) {
				this.getWaitBorrowService().remove(wbs);
			}
		}
		this.getArchivesManagerService().remove(archivesManager);
		
		return SUCCESS;
	}
	@Action(value = "removeArchivesManagerss", results = {
			@Result(name = "success", type = "redirect", location = "listArchivesManagers"),
			@Result(name = "error", type = "chain", location = "listArchivesManagers") })
	public String removeArchivesManagerss() {
		if (ids != null) {
			this.archivesManager = this.getArchivesManagerService().get(ids[0]);
		}
		if (archivesManager.getState()==1) {
			this.addActionError("此档案已被借出，不能删除");
			return ERROR;
		}
		ArchivesManager ams=this.getArchivesManagerService().getaArchivesManagers1(archivesManager.getId());
		if (ams!=null) {
			WaitBorrow wbs=this.getWaitBorrowService().getWaitBorrows(ams.getNumber());
			if (wbs!=null) {
				this.getWaitBorrowService().remove(wbs);
			}
		}
		this.getArchivesManagerService().remove(archivesManager);
		
		return SUCCESS;
	}
	@Action(value = "removeArchivesManagerSee", results = {
			@Result(name = "success", type = "redirect", location = "selectArchivesManagers"),
			@Result(name = "error", type = "chain", location = "selectArchivesManagers") })
	public String removeArchivesManagerSee() {
		if (ids != null) {
			this.archivesManager = this.getArchivesManagerService().get(ids[0]);
		}
		if (archivesManager.getState()==1) {
			this.addActionError("此档案已被借出，不能删除");
			return ERROR;
		}
		ArchivesManager ams=this.getArchivesManagerService().getaArchivesManagers1(archivesManager.getId());
		if (ams!=null) {
			WaitBorrow wbs=this.getWaitBorrowService().getWaitBorrows(ams.getNumber());
			if (wbs!=null) {
				this.getWaitBorrowService().remove(wbs);
			}
		}
		this.getArchivesManagerService().remove(archivesManager);
		
		return SUCCESS;
	}
	@Action("selectArchivate")
	public String selectArchivate(){
		return SUCCESS;
	}
	@Clew(results={"error"})
	@Action(value = "removeArchivesManagers", results = {
			@Result(name = "success", type = "redirect", location = "selectArchivates"),
			@Result(name = "error", type = "redirect", location = "selectArchivates") })
	public String removeArchivesManagers() {
		if (archivesManager.getState()==1) {
			this.setPrompt("此档案已被借出，不能删除");
			return ERROR;
		}
		ArchivesManager ams=this.getArchivesManagerService().getaArchivesManagers1(archivesManager.getId());
		if (ams!=null) {
			WaitBorrow wbs=this.getWaitBorrowService().getWaitBorrows(ams.getNumber());
			if (wbs!=null) {
				this.getWaitBorrowService().remove(wbs);
			}
		}
		this.getArchivesManagerService().remove(archivesManager);
		return SUCCESS;
	}

	@Action(value = "saveBorrow", results = {
			@Result(name = "success", type = "redirect", location = "listArchivesManagers"),
			@Result(name = "error", type = "chain", location = "listArchivesManagers") })
	public String saveBorrow() {
		if (ids != null) {
			this.archivesManager = this.getArchivesManagerService().get(ids[0]);
		}
		this.getArchivesManagerService().save(archivesManager);
		if (archivesManager.getState()==1) {
			this.addActionError("此档案已被借出，归还后请再借阅");
			return ERROR;
		}
		WaitBorrow wait = new WaitBorrow();
		if (wait != null) {
			wait.setNumber(archivesManager.getNumber());
			wait.setName(archivesManager.getArchivesName());
			wait.setAdress(archivesManager.getAdress());
			wait.setPage(archivesManager.getPage());
			wait.setText(archivesManager.getText());
			wait.setState(1);
			if (archivesManager.getArchivesType() != null) {
				wait.setArchivesType(archivesManager.getArchivesType()
						.getName());
			}
			if (archivesManager.getKeepTime() != null) {
				wait.setKeepTime(archivesManager.getKeepTime().getName());
			}
			if (archivesManager.getSecretLevel() != null) {
				wait.setSecretLevel(archivesManager.getSecretLevel().getName());
			}
			if (archivesManager.getAttach() != null) {
				wait.setAttach(archivesManager.getAttach().getName());
			}
			wait.setAppDate(archivesManager.getRecordTime());
			wait.setBorrowPerson(AppContext.getAccountContext().currentUser().getResume().getName());
		}
		this.getWaitBorrowService().save(wait);
		return SUCCESS;
	}
	@Action("listArchivesManagerByType")
	public String listArchivesManagerByType(){
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				ArchivesManager.class);
		criteria.add(Restrictions.in("archivesType", this.getArchivesManagerService().convertToArchivatesType(typeIds)));
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getArchivesManagerService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("listArchivesManagerByTypes")
	public String listArchivesManagerByTypes(){
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				ArchivesManager.class);
		criteria.add(Restrictions.in("archivesType", this.getArchivesManagerService().convertToArchivatesType(typeIds)));
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getArchivesManagerService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
	/******树形结构******/	
	@Action(value = "loadArchivatesTypeTree", results = { @Result(name = "success", type = "json",
			params = {"root", "nodes" }) })
	public String loadArchivatesTypeTree(){
		nodes = new ArrayList<TreeNode>();
		Collection<ArchivesType> reportFormCenters = this.getArchivesTypeService().getRootArchivesType();
		for (ArchivesType reportFormCenter : reportFormCenters) {
			TreeNode node = new TreeNode();
			node.setId(String.valueOf(reportFormCenter.getId()));
			node.setText(reportFormCenter.getName());
			addChildNode(reportFormCenter, node);
			nodes.add(node);
		}
		return SUCCESS;
	}
	

	
	private void addChildNode(ArchivesType reportFormCenter,TreeNode parentnode){
		if(reportFormCenter.getChilds() != null){
			for(ArchivesType form:reportFormCenter.getChilds()){
				TreeNode node = new TreeNode();
				node.setId(String.valueOf(form.getId()));
				node.setText(form.getName());
				parentnode.addChildNode(node);
				addChildNode(form, node);
			}
		}
	}
	@Action(value = "loadArchivatesTypeTrees", results = { @Result(name = "success", type = "json",
			params = {"root", "nodes" }) })
	public String loadArchivatesTypeTrees(){
		nodes = new ArrayList<TreeNode>();
		Collection<ArchivesType> reportFormCenters = this.getArchivesTypeService().getRootArchivesType();
		for (ArchivesType reportFormCenter : reportFormCenters) {
			TreeNode node = new TreeNode();
			node.setId(String.valueOf(reportFormCenter.getId()));
			node.setText(reportFormCenter.getName());
			addChildNodes(reportFormCenter, node);
			nodes.add(node);
		}
		return SUCCESS;
	}
	

	
	private void addChildNodes(ArchivesType reportFormCenter,TreeNode parentnode){
		if(reportFormCenter.getChilds() != null){
			for(ArchivesType form:reportFormCenter.getChilds()){
				TreeNode node = new TreeNode();
				node.setId(String.valueOf(form.getId()));
				node.setText(form.getName());
				parentnode.addChildNode(node);
				addChildNodes(form, node);
			}
		}
	}
	
	
	@Action("listPDMData")
	public String listPDMData(){
		ShareEim se=this.getShareEimService().getCode("se02");
		if (se!=null) {
			if (se.getState().equals("true")) {
				children=new ArrayList<Object[]>();
				ConnSqlServer cs=new ConnSqlServer();
				try {
					cs.getConn(se);
					Statement sta = ConnSqlServer.getCon().createStatement();
					rs=sta.executeQuery("select * from BOM_027");
					while (rs.next()) {
						t1=rs.getString("partid");
						t2=rs.getString("partvar");
						t3=rs.getString("kind");
						t4=rs.getString("source");
						t5=rs.getString("chinaname");
						t6=rs.getString("DESIGNDATE");			
						t7=rs.getString("model");
						t8=rs.getString("PARTSTATE");
						Object[] obj=new Object[]{t1,t2,t3,t4,t5,t6,t7,t8};
						children.add(obj);
					}
					rs.close();
					ConnSqlServer.getCon().close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
				return SUCCESS;
			}else{
				this.addActionError("未共享PDM，不能查看！");
				return ERROR;
			}
		}else{
			this.addActionError("未共享PDM，不能查看！");
			return ERROR;
		}
	}
}
